export function formatTimeDifference(timestamp) {
	// 获取当前时间戳
	const now = Date.now();
	// 计算时间差，单位为毫秒
	const diff = now - timestamp;

	// 将时间差转换为分钟、小时、天、月
	const minute = Math.floor(diff / (1000 * 60));
	const hour = Math.floor(diff / (1000 * 60 * 60));
	const day = Math.floor(diff / (1000 * 60 * 60 * 24));
	const month = Math.floor(diff / (1000 * 60 * 60 * 24 * 30));

	// 判断时间差范围并返回相应信息
	if (month >= 3) {
		return "超过三个月前";
	} else if (month > 0) {
		return `${month} 月前`;
	} else if (day > 0) {
		return `${day} 天前`;
	} else if (hour > 0) {
		return `${hour} 小时前`;
	} else if (minute > 0) {
		return `${minute} 分钟前`;
	} else {
		return '1 分钟内';
	}
}
export function gotoHome(){
	uni.showModal({
		title:"提示",
		content:"页面有误将返回首页",
		showCancel:false,
		success: (res) => {
			if(res.confirm){
				uni.reLaunch({
					url:"/pages/index/index"
				})
			}
		}
	})
}

